#ifndef __NetworkState_H__
#define __NetworkState_H__

#include <Ogre.h>

#include "GameState.h"

class NetworkState : public GameState
{
public:
	void enter();
	void exit();

	void pause();
	void resume();

	bool keyPressed(const OIS::KeyEvent &arg);
	bool keyReleased(const OIS::KeyEvent &arg);

	bool mouseMoved( const OIS::MouseEvent &arg );
	bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id );
	bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id );

	bool frameStarted(const Ogre::FrameEvent& evt);
	bool frameEnded(const Ogre::FrameEvent& evt);

	void createScene();
	void setupEventHandlers();
	bool handleBack(const CEGUI::EventArgs& e);
	bool handleStart(const CEGUI::EventArgs& e);
	bool handleMapSelection(const CEGUI::EventArgs& e);
	bool handleP1ColourChanged(const CEGUI::EventArgs &e);
	bool handleP2ColourChanged(const CEGUI::EventArgs &e);

	void drawSprites();

	static NetworkState* getInstance() { return &mNetworkState; }

protected:
	NetworkState();

	Ogre::Root *mRoot;
	Ogre::SceneManager* mSceneMgr;
	Ogre::Viewport* mViewport;
	DeviceManager* mDeviceManager;
	GUIManager* mGUIManager;
	OIS::Keyboard* mKeyboard;
	OIS::Mouse* mMouse;
	Ogre::Camera* mCamera;
	OgreAL::SoundManager *soundManager;
	OgreAL::Sound *sound;
	
	bool mGoBack;
	bool mStart;

	// Game GUI
	ChatBox* mChatBox;
	Ogre2dManager* spriteManager;

	// Models
	SceneNode* p1Avatar;
	SceneNode* p2Avatar;
	Entity* p1Mesh;
	Entity* p2Mesh;
	
	Overlay* mMapHolderOverlay;
    OverlayContainer* mSpaceDockContainer;
	OverlayContainer* mStoneHengeContainer;
	OverlayContainer* mVSContainer;
	MaterialPtr mapBlank;

	CEGUI::Scrollbar* p1RedScroll;
	CEGUI::Scrollbar* p1GrnScroll;
	CEGUI::Scrollbar* p1BluScroll;
	CEGUI::Scrollbar* p2RedScroll;
	CEGUI::Scrollbar* p2GrnScroll;
	CEGUI::Scrollbar* p2BluScroll;

private:
	static NetworkState mNetworkState;
};

#endif